﻿Imports System.Data.OleDb
Public Class TheLoaiPhimDAO
    Public Function Insert(ByVal tmp As TheLoaiPhimDTO) As Integer
        Dim cn As OleDbConnection = DataProvider.ConnectionData()
        Dim str As String = "insert into THELOAIPHIM (TenPhim, TenTheLoai) values (@TenPhim, @TenTheLoai)"
        Dim cmd As OleDbCommand = New OleDbCommand(str, cn)

        Dim para1, para2 As OleDbParameter
        para1 = New OleDbParameter("@TenPhim", tmp.TenPhim)
        cmd.Parameters.Add(para1)
        para2 = New OleDbParameter("@TenTheLoai", tmp.TenTheLoai)
        cmd.Parameters.Add(para2)

        Dim result As Integer = cmd.ExecuteNonQuery()
        cn.Close()
        Return result
    End Function

    Public Function Update(ByVal tmp As TheLoaiPhimDTO) As Integer
        Dim cn As OleDbConnection = DataProvider.ConnectionData()
        Dim str As String = "update THELOAIPHIM set TenTheLoai=@TenTheLoai where TenPhim=@TenPhim"
        Dim cmd As OleDbCommand = New OleDbCommand(str, cn)

        Dim para1, para2 As OleDbParameter
        para1 = New OleDbParameter("@TenBangCap", tmp.TenPhim)
        cmd.Parameters.Add(para1)
        para2 = New OleDbParameter("@MaBangCap", tmp.TenTheLoai)
        cmd.Parameters.Add(para2)

        Dim result As Integer = cmd.ExecuteNonQuery()
        cn.Close()
        Return result
    End Function

    Public Function Delete(ByVal tmp As TheLoaiPhimDTO) As Integer
        Dim cn As OleDbConnection = DataProvider.ConnectionData()
        Dim str As String = "delete from THELOAIPHIM where TenPhim=@TenPhim"
        Dim cmd As OleDbCommand = New OleDbCommand(str, cn)

        Dim para1 As OleDbParameter
        para1 = New OleDbParameter("@TenPhim", tmp.TenPhim)
        cmd.Parameters.Add(para1)

        Dim result As Integer = cmd.ExecuteNonQuery()
        cn.Close()
        Return result
    End Function
    Public Function GetTable(ByVal t As String) As DataTable
        Dim dt As DataTable = New DataTable()
        Dim cn As OleDbConnection = DataProvider.ConnectionData()
        Dim str As String = t
        Dim da As OleDbDataAdapter = New OleDbDataAdapter(str, cn)
        da.Fill(dt)
        cn.Close()
        Return dt
    End Function
    Public Function GetValue(ByVal t As String) As String
        Dim cn As OleDbConnection = DataProvider.ConnectionData()
        Dim str As String = t
        Dim cmd As OleDbCommand = New OleDbCommand(str, cn)
        Dim kq As String = cmd.ExecuteScalar()
        Return kq
    End Function
End Class
